package com.redis.queue.pub;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import redis.clients.jedis.Jedis;

public class Pub {
	private final Jedis jedis;
	
    private final String channel = "test1";

    public Pub(Jedis jedis) {
        this.jedis = jedis;
    }
    
    public void start() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String line = null;
            try {
                line = reader.readLine();
                if (!"quit".equals(line)) {
                	this.jedis.publish(channel, line);
                } else {
                    break;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
         }
    }
}
